Skip to content

Conversation

@boivie
Copy link
Collaborator

@boivie boivie commented Aug 29, 2025

It currently has a single function, to query the library's version, to validate that the C++ FFI is working correctly.

@ValorZard
Copy link

Is the plan for dcsctp to be an alternative to https://github.com/sctplab/usrsctp or https://github.com/webrtc-rs/sctp-proto
Additionally, will this support RFC 8620 to fix potential head-of-line blocking issues?
Let me know if this is the wrong place to ask this!

@boivie boivie force-pushed the feature-cxx branch 5 times, most recently from c1a35c5 to 4a36400 Compare December 1, 2025 08:56
@boivie boivie requested a review from lndmrk December 1, 2025 08:57
@@ -0,0 +1 @@
/examples/main
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this to the top level .gitignore instead? Makes it easier to maintain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


fn delete_socket(socket: *mut DcSctpSocket) {
if !socket.is_null() {
unsafe {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a // SAFETY: ... comment explaining why this is safe

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if !socket.is_null() {
unsafe {
// Re-take ownership of the Box and drop it.
let _ = Box::from_raw(socket);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do this instead?

drop(Box::from_raw(socket));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
}

unsafe fn state(socket: *const DcSctpSocket) -> ffi::SocketState {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a &DcSctpSocket instead of *const DcSctpSocket?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - much better

}
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? It's pub so why would it complain about being unused? Does this have to be pub by the way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see what CI says now.

This adds CXX FFI for the dcSCTP rust library to integrate it into a C++
application.
@boivie
Copy link
Collaborator Author

boivie commented Dec 1, 2025

Is the plan for dcsctp to be an alternative to https://github.com/sctplab/usrsctp or https://github.com/webrtc-rs/sctp-proto Additionally, will this support RFC 8620 to fix potential head-of-line blocking issues? Let me know if this is the wrong place to ask this!

Yeah, this is not really the right place, but: This is a Rust version of https://webrtc.googlesource.com/src/+/refs/heads/main/net/dcsctp, and the goal is to make this library have feature and stability parity with that one. Compared to e.g. usrsctp, this library only aims to implement the parts of SCTP that are required to support data channels in WebRTC, And yes, RFC8260 is supported.

@boivie boivie requested a review from lndmrk December 1, 2025 15:46
Box::into_raw(boxed_socket)
}

unsafe fn delete_socket(socket: *mut DcSctpSocket) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can move the unsafe block to only be around the drop call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, but as a raw pointer is passed in, I'm promising a lot. If garbage is passed in, bad things happen, so callers have to be careful and only pass valid data.

A well known LLM strongly suggests I should mark it as unsafe.

use dcsctp::api::SocketState as DcSctpSocketState;
use std::time::Instant;

#[cxx::bridge]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to add a namespace or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That commit got lost, done.

To avoid polluting the default namespace.
@boivie boivie merged commit 907e7ce into webrtc:main Dec 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants